package o;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol.Request;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appmarket.service.store.awk.bean.SubstanceDeeplinkCardBean;
import com.huawei.fastengine.fastview.Config;
import com.huawei.fastengine.fastview.download.utils.PackageUtils;
import com.huawei.hms.support.api.entity.hwid.HwIDConstant.ACTION;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.lang.ref.WeakReference;
import java.util.HashSet;
import java.util.Set;
import o.cii.c;
import o.dws.d;

public class dwv implements c {
    private static Set<String> ॱ = new HashSet();
    private String ˊ;
    private String ˎ;
    private BaseCardBean ˏ;

    static class a implements d {
        private String ˋ;
        private String ˎ;
        private WeakReference<Context> ˏ;
        private BaseCardBean ॱ;

        public a(Context context, BaseCardBean baseCardBean, String str, String str2) {
            this.ˏ = new WeakReference(context);
            this.ॱ = baseCardBean;
            this.ˎ = str;
            this.ˋ = str2;
        }

        public void aj_() {
            Context context = (Context) this.ˏ.get();
            if (context != null) {
                dwv.ˋ(context, this.ॱ, this.ˎ, this.ˋ);
            }
        }

        public void ak_() {
        }
    }

    public void ˏ(Context context, BaseCardBean baseCardBean) {
        if (context == null || baseCardBean == null) {
            Logger.ˋ("DeepLinkEventListener", "null == context || null == bean");
            return;
        }
        this.ˏ = baseCardBean;
        String ॱॱ = baseCardBean.ॱॱ();
        if (TextUtils.isEmpty(ॱॱ)) {
            Logger.ˋ("DeepLinkEventListener", "deailId is empty");
            return;
        }
        String[] split = ॱॱ.split("\\|");
        if (split.length < 3) {
            Logger.ˋ("DeepLinkEventListener", "invalid deailId" + ॱॱ);
            return;
        }
        String י = baseCardBean.י();
        String u_ = baseCardBean.u_();
        this.ˊ = split[1];
        if (TextUtils.isEmpty(this.ˊ)) {
            ॱ(context, this.ˊ, י, u_);
            return;
        }
        this.ˎ = split[2];
        if (baseCardBean instanceof SubstanceDeeplinkCardBean) {
            new dwz().ˏ(context, (SubstanceDeeplinkCardBean) baseCardBean, this.ˊ, this.ˎ);
        } else if ("com.huawei.gameassistant".equals(this.ˊ)) {
            new dxa().ˎ(context, this.ˏ, this.ˊ, this.ˎ);
        } else if (dwu.ˏ(this.ˎ)) {
            new dwu().ˋ(context, this.ˊ, this.ˎ, baseCardBean);
        } else if (!erz.ˏ(context, this.ˊ)) {
            ॱ(context, this.ˊ, י, u_);
        } else if (ˊ(this.ˊ)) {
            new dws(context, this.ˊ, ॱॱ, new a(context, baseCardBean, this.ˊ, this.ˎ)).ˏ(context);
        } else {
            ˋ(context, baseCardBean, this.ˊ, this.ˎ);
        }
    }

    public static String ˋ(String str) {
        String[] split = str.split("\\|");
        if (split.length < 3) {
            return "";
        }
        return split[2];
    }

    static void ॱ(Context context, String str, String str2, String str3) {
        cjo appDetailActivityProtocol = new AppDetailActivityProtocol();
        if (TextUtils.isEmpty(str2)) {
            str2 = drj.ॱ(str);
        }
        appDetailActivityProtocol.ˏ(new Request(str2, str3));
        cjk.ˎ().ˋ(context, new cjm("appdetail.activity", appDetailActivityProtocol));
    }

    private static Set<String> ˎ() {
        if (ॱ.isEmpty()) {
            ॱ.add(Config.FASTAPP_PACKAGE_NAME);
            ॱ.add(PackageUtils.HWGAMEBOX_PACKAGE_NAME);
            ॱ.add("com.huawei.educenter");
        }
        return ॱ;
    }

    public static boolean ˊ(String str) {
        boolean z = true;
        if (ˎ().contains(str)) {
            return false;
        }
        boolean z2;
        boolean equals = str.equals(fis.ˎ().getPackageName());
        Set ᐝ = euf.ˎ().ᐝ();
        if (ᐝ == null || !ᐝ.contains(str)) {
            z2 = false;
        } else {
            z2 = true;
        }
        if (z2 || equals) {
            z = false;
        }
        return z;
    }

    public static void ˊ(Context context, String str) {
        if (cku.ˏ(context, str)) {
            cku.ˎ(context, str);
        }
    }

    public static int ˋ(Context context, String str, String str2, String str3) {
        if (context == null) {
            Logger.ˋ("DeepLinkEventListener", "context == null");
            return -2;
        }
        int ˎ = dgm.ˎ((Activity) context);
        try {
            Intent intent = new Intent();
            intent.setAction(ACTION.HWID_SCHEME_URL);
            intent.setData(Uri.parse(str3));
            intent.setFlags(268435456);
            intent.setPackage(str2);
            context.startActivity(intent);
            cgo.ˋ(HwAccountConstants.TYPE_SECURITY_PHONE, str, ˎ);
            return 0;
        } catch (Exception e) {
            Logger.ˋ("DeepLinkEventListener", e.toString());
            return -1;
        }
    }

    private static void ˋ(Context context, BaseCardBean baseCardBean, String str, String str2) {
        int ˋ = ˋ(context, baseCardBean.ॱॱ(), str, str2);
        if (ˋ != -2) {
            if (ˋ == -1) {
                ॱ(context, str, baseCardBean.י(), baseCardBean.u_());
            }
            ˏ(context, baseCardBean.ॱॱ(), str, str2, ˋ);
        }
    }

    public static void ˏ(Context context, String str, String str2, String str3, int i) {
        dgh.ˋ("340301", evg.ॱ(str3, str, str2, dgm.ˎ((Activity) context), i));
    }
}
